/*******************************************************************************
 * Copyright (c) 2010 liw.
 * All rights reserved. 
 * 
 * This file is part of VanBus.
 * 
 *     VanBus is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     VanBus is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with VanBus.  If not, see <http://www.gnu.org/licenses/>.
 * Contributors:
 *     liw - initial API and implementation
 ******************************************************************************/
package org.niclab.vanbus.model;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;

public class SkyTrainLine {
	
	private String name;
	private List<SkyTrainRoute> routes = new ArrayList<SkyTrainRoute>();
	
	public SkyTrainLine(String name){
		
		this.name = name;
		
	}
	
	public String getName(){
		return this.name;
	}
	public void addSkyTrainRoute(SkyTrainRoute stl){
		this.routes.add(stl);
	}
	
	public SkyTrainRoute getSkyTrainRoute(int index){
		return routes.get(index);
	}
	
	
	
	public List<SkyTrainRoute> getRoutes() {
		return routes;
	}
	
	


	public static class SkyTrainRoute{
		
		private String start;
		private String end;
		
		public static String MonToFri = "Monday-Friday";
		public static String Sat = "Saturday";
		public static String Sun = "Sunday/Holiday";
		
		private HashMap<String, String[]> times = new HashMap<String, String[]>();

		public static String nextDay(String curDay){
			if(curDay.equals(SkyTrainRoute.MonToFri))
				return SkyTrainRoute.Sat;
			else if(curDay.endsWith(SkyTrainRoute.Sat))
				return SkyTrainRoute.Sun;
			else
				return SkyTrainRoute.MonToFri;
		}
		
		public static String prevDay(String curDay){
			if(curDay.equals(SkyTrainRoute.MonToFri))
				return SkyTrainRoute.Sun;
			else if(curDay.endsWith(SkyTrainRoute.Sat))
				return SkyTrainRoute.MonToFri;
			else
				return SkyTrainRoute.Sat;
			
		}
		
		public static String curDay(){
			int curDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
			if(curDay ==Calendar.SATURDAY)
				return Sat;
			else if(curDay == Calendar.SUNDAY)
				return Sun;
			else
				return MonToFri;
			
		}
		
		public String getStart() {
			return start;
		}

		public void setStart(String start) {
			this.start = start;
		}

		public String getEnd() {
			return end;
		}

		public void setEnd(String end) {
			this.end = end;
		}

		public HashMap<String, String[]> getTimes() {
			return times;
		}

		public void setTimes(HashMap<String, String[]> times) {
			this.times = times;
		} 
		
		public void addTime(String day, String[] times){
			this.times.put(day, times);
			
		}
		
		public String getFirstShiftTime(String day){
			return this.times.get(day)[0];
		}
		
		public String getLastShiftTime(String day){
			return this.times.get(day)[1];
		}
	}


}
